package org.example.service.impl;

import org.example.service.SchedulingService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class SchedulingServiceImpl implements SchedulingService {
    //每2秒执行一次 持续执行
    @Override
    @Scheduled(fixedRate = 2000)
    public void demo() {
        System.out.println("我是定时任务1！"+ LocalDateTime.now());
    }
    //每分钟的30秒的情况，执行一次
    @Scheduled(cron = "0,30 0/1 * * * *")
    public void demo01(){
        System.out.println("我是定时任务2！"+ LocalDateTime.now());
    }

    //每天凌晨2点更新
    @Scheduled(cron = "0 0 2 * * ? ")
    public void demo02(){
        System.out.println("我是定时任务2！"+ LocalDateTime.now());
    }
}
